import { asyncRoutes, constantRoutes } from '@/router';
const state = {
  routes: constantRoutes,
};
const mutations = {
  setRoutes(state, newRoutes) {
    state.routes = [...constantRoutes, ...newRoutes];
  },
};
const actions = {
  filterRoutes(context, menus) {
    const routes = [];
    menus.forEach((key) => {
      const reallyRoute = asyncRoutes.filter((item2) => {
        return item2.name === key;
      });
      routes.push(...reallyRoute);
    });
    context.commit('setRoutes', routes);
    return routes;
  },
};
export default {
  namespaced: true,
  state: state,
  mutations: mutations,
  actions: actions,
};
